/**
 * 
 * @param {待排序数组} arr 
 * @param {左边界} left 
 * @param {有边界} right 
 */
function quickSort(arr, left, right) {
  let head = left, rear = right
  let key = arr[head]
  while(head < rear) {
    while(head < rear && arr[rear] > key) rear--
    arr[head] = arr[rear]
    while(head < rear && arr[head] < key) head++
    arr[rear] = arr[head]
  }
  arr[head] = key
  if(head > left + 1) {
    quickSort(arr, left + 1, head)
  }
  if(head < right - 1) {
    quickSort(arr, head + 1, right)
  }
}
let arr = [3, 12, 2, 9, 0, 88]
quickSort(arr, 0, arr.length - 1)
console.log(arr);

